﻿<?php
include_once('common/header.php');	
$intPage		= $objRequest->getParam('page', 1);
$intLimit		= MEMBER_SEARCH_LIMIT;
$intTotal		= 0;
$intOff			= (($intPage-1) * $intLimit);
$objMember		= new Member();
if($AppUI->id > 0 || (isset($intAjax) && isset($intOwnerId) && $intOwnerId > 0 && $intAjax==1)) {
	if(!isset($intAjax)) $intOwnerId = $AppUI->id;
	$intAfrom		= 0;
	$intAto			= 0;
	$strPreference	= '';
	$strFriend		= '';
	$intGender		= 0;
	$intProvince	= 0;
	$objCommon 		= new Vfriend_Common();
	$objVfriendUser	= new Vfriend_User();	
	$strPreference	= $objVfriendUser->getPreference($AppUI->id);
	$strFriend		= $objVfriendUser->getRelation($AppUI->id);
	$intGender		= $AppUI->gender;
	$intProvince	= $AppUI->province;
	if($intGender == 1) {
		$intAfrom	= (int)($AppUI->ages - 5);
		$intAto		= $AppUI->ages;
	}elseif($intGender == 2) {
		$intAfrom	= $AppUI->ages;
		$intAto		= (int)($AppUI->ages + 5);
	}		
	$arrResult		= $objMember->match($intOwnerId, $intAfrom, $intAto, $intGender, $intProvince, $strPreference, $strFriend, $intOff, $intLimit, $intTotal);
} else {
	$intOwnerId		= 0;	
	$arrResult		= $objMember->getList($intOff, $intLimit, $intTotal);
}
if($intTotal >= MAX_DISPLAY) {
	$intTotal	= MAX_DISPLAY;
}
$this->view->arrResult		= $arrResult;
$this->view->intTotalPage	= ceil($intTotal / $intLimit);
$this->view->intPage 		= $intPage;			
$this->view->intOwnerId 	= $intOwnerId;			
?>